package cn.itcast.nems;

import cn.itcast.nems.config.FeignClientEncoder;
import org.apache.rocketmq.spring.autoconfigure.RocketMQAutoConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;

@EnableCaching
@SpringBootApplication
@ImportAutoConfiguration(value = {RocketMQAutoConfiguration.class})
@ComponentScan(basePackages = {"cn.itcast.nems","cn.itcast.ic"})
@EnableFeignClients(basePackages = {"cn.itcast.ic"}, defaultConfiguration = {FeignClientEncoder.class, FeignClientEncoder.FeignClientDecoder.class})
public class Emsv2Application implements ApplicationRunner {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Value("${spring.profiles.active}")
    private String active;

    @Value("${server.port}")
    private String serverPort;


    public static void main(String[] args) {
        SpringApplication.run(Emsv2Application.class, args);
    }

    @Override
    public void run(ApplicationArguments args) {
        logger.info("Active profile: " + active);
        logger.info("Listner port: " + this.serverPort);
    }
}
